var mongoose = require('mongoose');

const get = async ({page,limit,sort,status}) => {
    const result = {};
    const orderModel = mongoose.model("storeOrder");
    result.total = await orderModel.find({status});
    result.total = result.total.length;
    result.row = await orderModel
        .find({status})
        .skip((page - 1) * limit) //跳过
        .limit(limit) //限制
        .sort({
            _id: sort=="+1"?1:-1
        }) //排序
        .exec();
    result.maxPage = Math.ceil(result.total / limit);
    return result;
}

module.exports = {
    get,
}